Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

273 patch partitioningspartidparents #302

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

ABLL526
Copy link

@ABLL526 ABLL526 commented Nov 13, 2024

Adding get Ancestors feature:

  • PATCH /partitionings/{partId}/parents PATCH /partitionings/{partId}/parents #273
  • Removed 'Parent' wording to 'Ancestors' since there can be multiple parents going back 'generations'.
  • Similar to getFlowPartitionings
  • Any feedback, concern and questions are encouraged.

Feature 273 First Commit by Liam Leibrandt
Updated commit, updated tests.
@ABLL526 ABLL526 added enhancement New feature or request good first issue Good for newcomers DB Issues touching the Database part of the project Server Issues touching the server part of the project labels Nov 13, 2024
@ABLL526 ABLL526 added this to the v0.4.0 milestone Nov 13, 2024
@ABLL526 ABLL526 self-assigned this Nov 13, 2024
@ABLL526 ABLL526 linked an issue Nov 13, 2024 that may be closed by this pull request
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be ignored.
For my use.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be ignored.
For my use.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is it good for?
If for private use, don't put it into the repository.

Amended get ancestors functionality.
@@ -32,3 +32,10 @@ to remove them or
sbt flywayBaseline
```
to set the current state as the baseline.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This exact information is already in the readme file. Remove it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @salamonpavel will remove the file from the PR.

PartitioningWithIdDTO
], Any] = {
apiV2.get
.in(V2Paths.Partitionings / path[Long]("partitioningId") / V2Paths.Partitionings)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the path is very likely incorrect ...
according to this design #141 it should be /partitionings/{id}/parents
potentially we can thinks of using 'ancestors' instead

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct, again I think I was doing some testing. I will change it as necessary.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the path is very likely incorrect ... according to this design #141 it should be /partitionings/{id}/parents potentially we can thinks of using 'ancestors' instead

ancestors is better IMHO.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah why not, I'm okay with it. ALthough, potentially consider writing something short about it here in our Vocabulary documentation section: https://github.com/AbsaOSS/atum-service?tab=readme-ov-file#Vocabulary

], Any] = {
apiV2.get
.in(V2Paths.Partitionings / path[Long]("partitioningId") / V2Paths.Parents / path[Long]("partitioningId") / V2Paths.Parents )
.in(query[String]("byUser"))
Copy link
Collaborator

@salamonpavel salamonpavel Nov 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there should be no query parameters, only request body ...
put the user into the body of the request

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood, will fix.

ParentPatchV2DTO
], Any] = {
apiV2.get
.in(V2Paths.Partitionings / path[Long]("partitioningId") / V2Paths.Parents / path[Long]("partitioningId") / V2Paths.Parents )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

incorrect path

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct, I think I was doing some testing. Will change to the correct path.

@@ -33,7 +33,7 @@ addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.2.0")
lazy val ow2Version = "9.5"
lazy val jacocoVersion = "0.8.11-absa.1"

def jacocoUrl(artifactName: String): String = s"https://github.com/AbsaOSS/jacoco/releases/download/$jacocoVersion/org.jacoco.$artifactName-$jacocoVersion.jar"
def jacocoUrl(artifactName: String): String = s"file:///C:/Users/ABLL526/Documents/GitHub/Jar-Store2/org.jacoco.$artifactName-$jacocoVersion.jar"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

???

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this was for my use only. Will remove the file from the PR.

@@ -46,4 +46,4 @@ addSbtPlugin("org.ow2.asm" % "asm" % ow2Version from ow2Url("asm"))
addSbtPlugin("org.ow2.asm" % "asm-commons" % ow2Version from ow2Url("asm-commons"))
addSbtPlugin("org.ow2.asm" % "asm-tree" % ow2Version from ow2Url("asm-tree"))

addSbtPlugin("za.co.absa.sbt" % "sbt-jacoco" % "3.4.1-absa.4" from "https://github.com/AbsaOSS/sbt-jacoco/releases/download/3.4.1-absa.4/sbt-jacoco-3.4.1-absa.4.jar")
addSbtPlugin("za.co.absa.sbt" % "sbt-jacoco" % "3.4.1-absa.4" from "file:///C:/Users/ABLL526/Documents/GitHub/Jar-Store2/sbt-jacoco-3.4.1-absa.3.jar")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

???

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this was for my use only. Will remove the file from the PR.

PERFORM 1 FROM runs.partitionings WHERE id_partitioning = i_parent_id;
IF NOT FOUND THEN
status := 41;
status_text := 'Parent Partitioning not found';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, we could distinguish was was not found.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed

AND fk_flow != mainFlow
);

FOREACH var IN ARRAY flow_id LOOP
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loops could be removed

* limitations under the License.
*/

CREATE OR REPLACE FUNCTION runs.patch_partitioning_parent(
Copy link
Collaborator

@salamonpavel salamonpavel Nov 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure about what the function does and is supposed to do. I thought we should check that partitioning and parent partitioning exists and then simply add the relationship (if not already there) using _add_to_parent_flows.sql ... @benedeki @lsulak

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function should set the relationship between the two partitions, considering the conditions are set. And based on input parameter(s) copy the metadata from parent to child.
Conditions to check:

  • partition exists
  • parent partition exists
  • the relationship does not exist already (then it's not an error, just no-op)
  • a reverse relationship does not exist
    Metadata to copy, if input parameters says so:
  • measures
  • additional data

partitioningId: Long,
parentPartitioningID: Long,
byUser: String
): IO[ErrorResponse, SingleSuccessResponse[ParentPatchV2DTO]]
Copy link
Collaborator

@salamonpavel salamonpavel Nov 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure about the return value. Usually PATCH returns updated resource. In our case though we edit/establish relationship in the db. I wonder if instead we should return 200 OK with partitioning and all its parent partitionings or return 200 Ok without data or 204 No Content.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am for 200 Ok without any data, or 204 No Content.

  • the Id makes no sense
  • the partitioning doesn't give much value
  • and partitioning with all parents while occasionally useful could be taxing on the DB - better to request explicitly for those rare occasions

Comment on lines 73 to 80
flow_id := array(
SELECT fk_flow AS flow_id
FROM flows.partitioning_to_flow
WHERE fk_partitioning = i_partitioning_id
AND fk_flow != mainFlow
);

FOREACH var IN ARRAY flow_id LOOP
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Work with Arrays in PG is nto very effective. It's discouraged to operate on them, only use them as input or output.
Particularly bad is to do a FOR loop over them.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is it good for?
If for private use, don't put it into the repository.

partitioningId: Long,
parentPartitioningID: Long,
byUser: String
): IO[ErrorResponse, SingleSuccessResponse[ParentPatchV2DTO]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am for 200 Ok without any data, or 204 No Content.

  • the Id makes no sense
  • the partitioning doesn't give much value
  • and partitioning with all parents while occasionally useful could be taxing on the DB - better to request explicitly for those rare occasions

PartitioningWithIdDTO
], Any] = {
apiV2.get
.in(V2Paths.Partitionings / path[Long]("partitioningId") / V2Paths.Partitionings)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the path is very likely incorrect ... according to this design #141 it should be /partitionings/{id}/parents potentially we can thinks of using 'ancestors' instead

ancestors is better IMHO.

@@ -32,6 +32,12 @@ trait PartitioningController {
partitioningSubmitDTO: PartitioningSubmitV2DTO
): IO[ErrorResponse, (SingleSuccessResponse[PartitioningWithIdDTO], String)]

def patchPartitioningParentV2(
Copy link
Collaborator

@lsulak lsulak Dec 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My suggestion: try to create smaller PRs. In this case, all this could be split into 2 PRs:

  • SQL stuff only, with Balta tests that would test proposed DB functions
  • Scala part related to the backend - controller, service, repository, scala classes related to DB function wrapping/calls, etc

Also, not only splitting, but approaching this as a 2 step process can save you time, i.e. no need to implement the second part if your DB functions are not yet working or aren't satisfying API and/or functionality completely

: PublicEndpoint[(Long, Long, String), ErrorResponse, SingleSuccessResponse[
ParentPatchV2DTO
], Any] = {
apiV2.get
Copy link
Collaborator

@lsulak lsulak Dec 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also should be patch right? Not get

package za.co.absa.atum.server.api.http

import org.mockito.Mockito.{mock, when}
import sttp.client3.circe.asJson
Copy link
Collaborator

@lsulak lsulak Dec 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few unused imports below

This is specifically for the database portion.
1. Changed functionality to simply add a parent.
2. Can copy the Measurements from parent.
3. Can copy the Additional Data from parent.
This is specifically for the database portion.
1. Made the necessary changes as mentioned by the team.
1. Made the necessary changes as mentioned by the team.
2. Made the necessary changes to the add parent Database functionality.
3. Made the necessary changes to the get ancestors Database functionality.
4. Made the necessary changes to the get ancestors Scala implementation.

I still need to add the add parents Scala functionality.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DB Issues touching the Database part of the project enhancement New feature or request good first issue Good for newcomers Server Issues touching the server part of the project
Projects
Status: No status
4 participants